<?php

/* @var $this yii\web\View */

use yii\helpers\Html;

$this->title = 'My Yii Application';
$css = '.col-xs-3:after{content:"a";font-size:20px;width:60px;height:40px}';
$this->registerCss($css);

$js = <<<JS
function ChangeToDFM()
{
		var du = document.getElementById("input_du").value;
		var str1 = du.split(".");
		var du1 = str1[0];
		var tp = "0."+str1[1]
		var tp = String(tp*60);		//这里进行了强制类型转换
		var str2 = tp.split(".");
		var fen =str2[0];
		tp = "0."+str2[1];
		tp = tp*60;
		var miao = tp;
		document.getElementById("calculated_DFM").innerHTML = du1+"°"+fen+"'"+miao+"\"";
}

function changeToDu(dfm) {
    var flag=1;
    if(dfm.match(/[nNeE]/)){
        dfm=dfm.replace(/[nNeE]/,'');
        flag=1;
    }
	if(dfm.match(/[sSwW]/)){
        dfm=dfm.replace(/[sSwW]/,'');
        flag=-1;
    }
    dfm=dfm.replace(/["]/,'');
	
    const arr1 = dfm.split('°');
    const d = arr1[0];
    const arr2 = arr1[1].split("'")
    let f = arr2[0] || 0;
    const m = arr2[1] || 0;
    f = parseFloat(f) + parseFloat(m / 60);
    var du = parseFloat(f / 60) + parseFloat(d);
    return du;
}

$(document).ready(function(){
                        $('#myTab a').click(function(){
                            $(this).tab('show')
                        })
                    });

JS;
$this->registerJs($js);
?>
<div class="site-index">

    <div class="body-content">

        <form id="form">
            <span>
                <h2 class="h24">度分秒转换</h2>
                <hr/>
                <div class="form-group">

                        <span class="col-lg-5 col-xs-5 col-sm-5">
                            <label>度</label>
                            <textarea name="words" class="form-control " rows="3" placeholder="允许多行"></textarea>
                        </span>

                    <span class="col-lg-2 col-xs-2 col-sm-2 text-center">
                            <label>&nbsp;</label>
                        <button type="button" class="btn btn-primary" id="sumit">&gt;&gt;</button>
                        <button type="button" class="btn btn-default" id="sumit">&lt;&lt;</button>
                        </span>

                    <span class="col-lg-5 col-xs-5 col-sm-5">

                            <label>度分秒</label>
                        <textarea name="words" class="form-control col-xs-5" rows="3" placeholder=""></textarea>
                            </span>

                </div>

                <span class="form-group">
                    <label>格式化输入：</label>
                    <span class="row list-inline">
                    <div class="col-sm-3 col-xs-3"><input type="number" name="tone" value="1" id="r1f" class="form-control"  /></div>
                    <span>°</span>
                    <div class="col-sm-3 col-xs-3"><input type="number" name="tone" value="1" id="r1" class="form-control" /></div>
                    <span>′</span>
                    <div class="col-sm-3 col-xs-3"><input type="number" name="tone" value="1" id="r1" class="form-control" /></div>
                    <span>″</span>
                    </div>
                </div>
            </div>


        </form>

    </div>
</div>
